package net.codesree.dao;

import javax.sql.DataSource;

import net.codesree.dao.JDBCTemplate;
import net.codesree.dao.DAOException;

public abstract class AbstractJDBCDaoImpl {

 private JDBCTemplate jdbcTemplate=null;
 
 public AbstractJDBCDaoImpl(DataSource _dSource) {
  this.jdbcTemplate=new JDBCTemplate(_dSource);
 }
 
 public int countRowsOfTable(String tableName) throws DAOException {
  StringBuffer strBuffer=new StringBuffer("SELECT COUNT(*) FROM "+tableName);
  return countRows(strBuffer.toString());
 }
 
 public int countRows(String queryStr) throws DAOException {
  return this.jdbcTemplate.queryForInt(queryStr,null);
 }
 
 public abstract boolean exists(String queryStr) throws DAOException;

}